﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IllustratedCsharp7_ch20_Linq
{
    //let子句接受一个表达式的运算并且把它赋值给一个需要在其他运算中使用的标识符
    class chapt20_5_4LetClause
    {
        static void _Main() {
            var groupA = new[] { 3, 4, 5, 6 };
            var groupB = new[] { 6, 7, 8, 9 };

            var someInts = from a in groupA
                           from b in groupB
                           let sum = a + b      //在新的变量中保存结果
                           where sum == 12
                           select new { a, b, sum };

            foreach (var a in someInts)
                Console.WriteLine(a);
        }
    }
}
